#include "direction.hpp"

namespace jam {

template<>
std::string to_string(const direction_t &direction) {
  std::string literal;
  switch (direction) {
#define LAZY_CASE(x) case x: literal = std::string(LITERAL_OF(x)); break
    ITERATE_ESWNU(LAZY_CASE);
#undef LAZY_CASE
  }
  return literal;
}

Directions::Directions(std::string &directions_literal) {
  for (char direction : directions_literal) {
    switch (direction) {
#define READS_AS(d, c) case c: push_back(d); break
      ITERATE_ESWN_ARG(READS_AS, 'e', 's', 'w', 'n');
      CONTINUE_ON_UNDEF;
#undef READS_AS
    }
  }
}

}
